package com.red.result;

import java.util.HashMap;
import java.util.Map;

public class Result extends HashMap<String,Object> {
    public Result(){
        put("code","200");
        put("msg","success");
    }
    public Result(Object data){
        put("code","200");
        put("msg","success");
        put("data",data);
    }

    /**
     * 异常
     * @return
     */
    public static Result error(int code,String msg){
        Result result = new Result();
        result.put("code", code);
        result.put("msg", msg);
        return result;
    }

    /**
     * 正确结果
     * @param map
     * @return
     */
    public static Result ok(Map<String,Object> map){
        Result result = new Result();
        result.putAll(map);
        return result;
    }
}
